package pg

import (
	"database/sql"

	_ "github.com/lib/pq"
	"gorm.io/driver/postgres"
	"gorm.io/gorm"
)

var Db *sql.DB

func Connected() *gorm.DB {
	// connStr := "user=postgres password=pdaesd dbname=postgres sslmode=disable"
	// Db, _ = sql.Open("postgres", connStr)

	// defer Db.Close()

	// return Db
	dsn := "user=postgres password=pdaesd dbname=postgres sslmode=disable"
	db, err := gorm.Open(postgres.Open(dsn), &gorm.Config{})
	if err != nil {
		panic(err)
	}

	return db
}
